home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / windows5 / v11n18.zip / DAYS.ZIP / DAYS2.PRG < prev   
Text File  |  1992-06-08  |  1KB  |  42 lines

  1. * DAYS2.PRG
  2. * This program calculates the number of times each day of the week
  3. * occurs within a given range of dates. dBASE IV.
  4. *
  5. SET TALK OFF
  6. CLEAR
  7. STORE CTOD("  /  /  ") TO beg_date,end_date
  8.  
  9. @ 3,3 SAY "Enter beginning date:" GET beg_date
  10. @ 5,3 SAY "Enter ending date:   " GET end_date
  11. READ
  12.  
  13. ?
  14. ? "Number of Sundays is   " + STR(DayOccurs(beg_date,end_date,1))
  15. ? "Number of Mondays is   " + STR(DayOccurs(beg_date,end_date,2))
  16. ? "Number of Tuesdays is  " + STR(DayOccurs(beg_date,end_date,3))
  17. ? "Number of Wednesdays is" + STR(DayOccurs(beg_date,end_date,4))
  18. ? "Number of Thursdays is " + STR(DayOccurs(beg_date,end_date,5))
  19. ? "Number of Fridays is   " + STR(DayOccurs(beg_date,end_date,6))
  20. ? "Number of Saturdays is " + STR(DayOccurs(beg_date,end_date,7))
  21. ?
  22. RETURN
  23.  
  24. * FUNCTION DayOccurs
  25. * Returns the number of times a day occurs in a date
  26. * range.  For example, to find how many Sundays there
  27. * are in between 1/15/91 and 1/31/91 use:
  28. *
  29. * startd = CTOD("01/15/91")
  30. * endd = CTOD("01/31/91")
  31. * answer = DayOccurs(startd, endd, 1)
  32. *
  33. * 1 means Sunday, 2 means Monday etc.
  34. *
  35. FUNCTION DayOccurs
  36. PARAMETERS begdate, enddate, daynumba
  37. PRIVATE numdays, dayofw, x, result
  38. numdays = enddate - begdate + 1
  39. dayofw = DOW(begdate)
  40. x = daynumba - dayofw + IIF(daynumba < dayofw,8,1)
  41. RETURN INT(numdays/7) + IIF(x <= MOD(numdays,7),1,0)
  42.